package com.hxut.controller;

import com.hxut.dao.MenuDao;
import com.hxut.domain.MainMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * description: MenuController
 * date: 2022/6/15 18:25
 * author: MR.孙
 */
@RestController
public class MenuController {
    @Autowired
    private MenuDao menuDao;

    @RequestMapping("/menus")
    public Map<String,Object> getAllMenus(){
        HashMap<String,Object> menuMap=new HashMap<>();
        List<MainMenu> menus = menuDao.getMainMenus();
        if(menus!=null){
            menuMap.put("menus",menus);
            menuMap.put("flag",200);//状态码200代表成功
        }else{
            menuMap.put("flag",404);

        }
        return menuMap;
    }
}
